﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace TeachingAffairsManagementSystem.WebControl
{
    public partial class AlertBox : System.Web.UI.UserControl
    {
        public enum Level
        {
            Success,
            Info,
            Warning,
            Danger
        }


        protected void Page_Load(object sender, EventArgs e)
        {
        }

        public void Show(string text, Level level, bool isCenter)
        {
            LText.Text = text;
            Alert.Attributes.Add("class", "alert");

            SetAlertLevel(level);
            if (isCenter)
            {
                SetCenter();
            }

            Alert.Visible = true;
        }


        private void SetAlertLevel(Level level)
        {
            switch (level)
            {
                case Level.Success:
                    Alert.Attributes.Add("class", Alert.Attributes["class"] + " alert-success");
                    break;
                case Level.Info:
                    Alert.Attributes.Add("class", Alert.Attributes["class"] + " alert-info");
                    break;
                case Level.Warning:
                    Alert.Attributes.Add("class", Alert.Attributes["class"] + " alert-warning");
                    break;
                case Level.Danger:
                    Alert.Attributes.Add("class", Alert.Attributes["class"] + " alert-danger");
                    break;
            }
        }

        private void SetCenter()
        {
            Alert.Attributes.Add("class", Alert.Attributes["class"] + " text-center");
        }
    }
}